<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Vuex使用State</title>
  <script src="../../node_modules/vue/dist/vue.js"></script>
  <script src="../../node_modules/vuex/dist/vuex.js"></script>
</head>
<body>
  <div id="app">
    <h2>{{msg}}</h2>
    <modal></modal>
  </div>
</body>
<script>
  const modal = {
    template: '<div>{{ count }}</div>',
    computed:{
      count () {
        return this.$store.state.count
      }
    }
  }
  // 创建Store
  let store = new Vuex.Store({
    state:{
      count: 10
    }
  })
  // 生成vue实例
  new Vue({
    el:'#app',
    data:{
      msg:'Vuex基础'
    },
    store,
    components:{
      modal
    }
  })
</script>
</html>